import './App.css';
import React, { Component,lazy, Suspense } from 'react';
import { Route, Switch, Redirect } from 'react-router-dom';
import './assets/font_3851000_bsk1cpbnyqt/iconfont.css'

var Index = lazy(()=>import('./views/Index'))//首页
var Register = lazy(()=>import('./views/Register'))//注册页面
var Login = lazy(()=>import('./views/Login'))//登陆页面
var UserAdderss = lazy(()=>import('./views/UserAdress'))//收货地址
var AddAddress = lazy(()=>import('./views/AddAddress'))//新增收货地址
var SortCity = lazy(()=>import('./views/SortCity'))//城市列表
var SetUser = lazy(()=>import('./views/SetUser'))//用户设置
var Detail = lazy(()=>import('./views/Detail'))//商品详情页面
var UserOrder = lazy(()=>import('./views/UserOrder'))//订单
var Search = lazy(()=>import('./views/Search'))//搜索页面
var searchResult = lazy(()=>import('./views/searchResult'))//搜索商品展示页面
var EditAddress = lazy(()=>import('./views/EditAddress'))//编辑地址
var Gopay = lazy(()=>import('./views/Gopay'))
var ConfirmOrder = lazy(()=>import('./views/ConfirmOrder'))
var Collection = lazy(()=>import('./views/collection'))
var NotFound = lazy(()=>import('./views/NotFound'))

class App extends Component {
   constructor(props){
    super(props)
    this.state={
  
    }
   }
  render() {
    return (
      <div className='app'  key={this.state.key}>
       <Suspense fallback={<div  className='loading'>< img src="https://hbimg.b0.upaiyun.com/5ac0d375bfb83e892b4884bb1d7e5046d223da2d2bd08-LrjhBO_fw658" alt="" /></div>}>
          <Switch>
            <Route path="/index" component={Index} />
            <Route exact path="/login" component={Login} />
            <Route path="/register" component={Register} />
            <Route exact path="/useraddress" component={UserAdderss} />
            <Route exact path="/addaddress" component={AddAddress} />
            <Route exact path="/sortcity" component={SortCity} />
            <Route exact path="/setuser" component={SetUser} />
            <Route exact path="/detail" component={ Detail} /> 
            <Route exact path="/userorder" component={UserOrder} />
            <Route exact path="/search" component={Search} />
            <Route exact path="/searchResult" component={searchResult} />
            <Route exact path="/EditAddress" component={EditAddress} />
            <Route exact path="/Gopay" component={Gopay} />
            <Route exact path="/ConfirmOrder" component={ConfirmOrder} />
            <Route exact path="/Collection" component={Collection} />
            <Redirect exact from='/' to="/index" /> 
            <Route path="*" component={NotFound} /> //404路由
          </Switch>
        </Suspense>
      </div>
    );
  }
}

export default App;